package com.sms.service.impl;

import java.util.Date;
import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sms.dao.ClassDAO;
import com.sms.model.PageBean;
import com.sms.pojo.SmsClass;
import com.sms.service.ClassService;
import com.sms.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ClassServiceImpl implements ClassService {

    @Autowired
    private ClassDAO classDao;

    @Override
    public synchronized void addClass(SmsClass smsClass) {
        String classId = StringUtils.getId(classDao.getMaxId());
        smsClass.setClassId(classId);
        smsClass.setCreateTime(new Date());
        classDao.addClass(smsClass);
    }

    @Override
    public PageInfo<SmsClass> queryClassPage(Integer page, Integer pageSize, SmsClass smsClass) {
        /*拦截分页信息*/
        PageHelper.startPage(page, pageSize);
        List<SmsClass> classes = classDao.queryClass(smsClass);

        return new PageInfo<>(classes);
    }


}
